﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using br.com.SistemaChamados.Enum;
using br.com.SistemaChamados.Model;
using br.com.SistemaChamados.DAO;
using System.Data;

/// <summary>
/// Summary description for PlaceController
/// </summary>
/// 

namespace br.com.SistemaChamados.Controller
{
    public class PlaceController
    {
        public EnumGenericState UpdatePlace(Place place)
        {
            EnumGenericState resultPlace = EnumGenericState.GENERIC_STATE_UNKNOW;
            try
            {
                PlaceDAO placeDAO = new PlaceDAO();
                resultPlace = placeDAO.UpdatePlace(place);
            }
            catch (Exception ex)
            {
                resultPlace = EnumGenericState.GENERIC_STATE_FAILED;
                throw ex;
            }
            return resultPlace;
        }

        public List<Place> GetPlaces()
        {
            List<Place> listPlace = null;
            PlaceDAO placeDAO = null;
            try
            {
                placeDAO = new PlaceDAO();
                listPlace = placeDAO.GetPlaces();
                if (listPlace != null)
                {
                    return listPlace;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception ex)
            {
                return null;
                throw ex;
            }
        }

        public Place GetPlace(Place place)
        {
            Place resultPlace = null;
            PlaceDAO placeDAO = null;
            try
            {
                placeDAO = new PlaceDAO();
                resultPlace = placeDAO.GetPlace(place);
                if (resultPlace != null)
                {
                    return resultPlace;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception ex)
            {
                return null;
                throw ex;
            }
        }

        public EnumGenericState DeletePlace(Place place)
        {
            EnumGenericState resultPlace = EnumGenericState.GENERIC_STATE_UNKNOW;
            try
            {
                PlaceDAO placeDAO = new PlaceDAO();
                resultPlace = placeDAO.DeletePlace(place);
            }
            catch (Exception ex)
            {
                resultPlace = EnumGenericState.GENERIC_STATE_FAILED;
                throw ex;
            }
            return resultPlace;
        }

        public EnumGenericState InsetPlace(Place place)
        {
            EnumGenericState resultPlace = EnumGenericState.GENERIC_STATE_UNKNOW;
            try
            {
                PlaceDAO PlaceDAO = new PlaceDAO();
                resultPlace = PlaceDAO.InsertPlace(place);
            }
            catch (Exception ex)
            {
                resultPlace = EnumGenericState.GENERIC_STATE_FAILED;
                throw ex;
            }
            return resultPlace;
        }
        public PlaceController()
        {
            //
            // TODO: Add constructor logic here
            //
        }
    }
}